#!/bin/bash

app_port=$(echo ${HTTP_KPORT} | awk -F '[ :]+' '{print $NF}')
if [ -z "$app_port" ]
then
    echo "app_port is empty"
else
    sed -ri 's#:9091;#:'${app_port}';#'  /etc/nginx/vhost/upstream.conf
fi

chown -R :tty /dev/
chmod -R g+rwx /dev/
chmod a+rw /dev/std*
exec /opt/app-serve/gosu-arm64 cams /usr/bin/supervisord -n
wait